<?php
/**
 * 把系统管理设置为最高优先级
 */

$host = '113.44.136.17';
$port = 3306;
$database = 'qiandao';
$username = 'qiandao';
$password = 'NGbks3HWx5PhSxDX';

try {
    $pdo = new PDO("mysql:host={$host};port={$port};dbname={$database};charset=utf8mb4", $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    echo "=== 设置系统管理为最高优先级 ===\n\n";
    
    // 把系统管理的 SORT 设置为 200（最高）
    $stmt = $pdo->prepare("UPDATE system_menu SET sort = 200 WHERE id = 1");
    $stmt->execute();
    
    echo "✓ 已将系统管理的 SORT 设置为 200\n\n";
    
    // 查看当前排序
    $stmt = $pdo->query("
        SELECT id, title, sort 
        FROM system_menu 
        WHERE pid = 0 AND status = 1 
        ORDER BY sort DESC, id ASC
    ");
    
    echo "当前一级菜单排序：\n";
    foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $menu) {
        echo "  {$menu['title']} (ID:{$menu['id']}, SORT:{$menu['sort']})\n";
    }
    
    echo "\n请刷新后台页面（Ctrl+F5）查看效果\n";
    
} catch (PDOException $e) {
    echo "数据库错误: " . $e->getMessage() . "\n";
}

